/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.oplevka.lahvodroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

/**
 *
 * @author Ondra
 */
public class MapView extends Activity {
    private static XMLBeerList xmlBeerList = null;
    HashMap<String,ArrayList<String>> meMap;
    HashMap<String,String> nameMap;
    int order;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.datab);
        xmlBeerList = XMLHandler.xmlBeerList;
//        meMap = xmlBeerList.getMap();
//        nameMap = xmlBeerList.getNameMap();
        TextView textView = new TextView(this);
        textView.setTextSize(20);
//        if(!meMap.isEmpty()){
//            textView.setText("Mapa je plna\n");
//        } else {
//            textView.setText("Mapa je prazdna\n");
//        }
        
        
        String getKey = MyListView.getBeer();
        String tempKey = xmlBeerList.getNameMap().get(getKey);
        ArrayList<String> value = (ArrayList<String>) 
                xmlBeerList.getMap().get(tempKey);
        textView.setText("Detail piva:\n"+"Barcode: "+tempKey+"\n");
        Iterator it;
//        ArrayList<String> value = (ArrayList<String>) meMap.get(key);
                it = value.iterator();
                order = 0;
                while (it.hasNext()) {
                    switch (order){
                        case 0:
                            textView.append("Jmeno: ");
                            order++;
                            break;
                        case 1:
                            textView.append("Pivovar: ");
                            order++;
                            break;
                        case 2:
                            textView.append("% Alkoholu: ");
                            order++;
                            break;
                        case 3:
                            textView.append("Poznámka: ");
                            break;
                    }
                    
                    String s = (String) it.next();                                       
                    textView.append(s+"\n");           
                    
                }
                

        
//        Iterator myVeryOwnIterator = meMap.keySet().iterator();
//        Iterator it;
//        while(myVeryOwnIterator.hasNext()) {
//                String key=(String)myVeryOwnIterator.next();
//                textView.append(key+"\n"+"_____________\n");
//                
//                ArrayList<String> value = (ArrayList<String>) meMap.get(key);
//                it = value.iterator();
//                while (it.hasNext()) {
//                    String s = (String) it.next();
//                    textView.append(s+"\n");
//                }                
//        }
        setContentView(textView);
    }
}
